package org.dei.perla.test.llqruntime.simulator;

import java.util.*;

import org.dei.perla.parser.clauses.*;
import org.dei.perla.parser.expressions.NodeLogicalObjectAttribute;
import org.dei.perla.parser.statements.*;
import org.dei.perla.sys.device.fpc.*;
import org.dei.perla.sys.query.llqruntime.datastructures.*;
import org.dei.perla.utils.messages.AdapterFpcMessage;
import org.dei.perla.utils.pipe.Pipe;


public class FPCmockup extends FunctionalityProxyComponent {

	public FPCmockup(String parName, Pipe<AdapterFpcMessage> inputPipe) {
		super(parName, inputPipe, null);
	}

	//Il device astratto dall'FPC
	private DeviceMockup pFakeDevice;
	
	//Mapping QueryDaServire <-> Attivita' di sampling
	private HashMap<LLStatement,SingleSamplingActivity> pActiveQueries = new HashMap<LLStatement,SingleSamplingActivity>();
 	
	//Registra la query (i.e.: inizia a produrre)
	public void registerQueryOnFPC(LLStatement parStatement) {
		
		SingleSamplingActivity t = new SingleSamplingActivity(pFakeDevice);
		t.start();
		this.pActiveQueries.put(parStatement, t);
		
	}
	
	//Per l'interrogazione dal registry
	public QueryRecordStructure getFPCAttributes() {
		return pFakeDevice.getSamplableAttributes();
	}
	
	//Restituisce il nome dell'FPC (A,B,C...)
	public String getFPCName() {
		return this.getName();
	}
	
	//Espone la pipe associate ad una query
	public Pipe<Record> getPipe(LLStatement parStatement) {
		return this.pActiveQueries.get(parStatement).getPipe();
	}

	//Setta la frequenza di produzione
	public boolean setMockupSamplingTime(long parTime,OnUnsupportedSampleRateOptions parBehaviour,LLStatement parStat) {
		this.pActiveQueries.get(parStat).setSamplingFrequency(parTime);
		return true;
		
	}
	
	@Override
	public boolean registerQuery(Statement parStatement) {
		// TODO Auto-generated method stub
		return true;
	}


	@Override
	public boolean setSamplingTime(long parTime, OnUnsupportedSampleRateOptions parBehaviour) {		
		return true;
	}

	@Override
	public ArrayList<Record> forceSampling() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ArrayList<NodeLogicalObjectAttribute> getAttributeList() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void initDefault() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void pipeClosedCallBack(Pipe<AdapterFpcMessage> pipe) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void readMessageFromAdapter(byte[] payload) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean unRegisterQuery() {
		// TODO Auto-generated method stub
		return false;
	}
		

}
